home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / fido / RFS275.lha / rexx / RFH.rexx < prev    next >
OS/2 REXX Batch file  |  1995-04-17  |  26KB  |  622 lines

  1. /**/
  2. v="$VER: RFH Rexx WPL Mailer File Request Function Host Williamson 56.28"
  3. compiled=1  /* Set to 1 before compiling! */
  4. if ~show('L', "rexxdossupport.library") then
  5. if ~addlib("rexxdossupport.library", 0, -30, 2) then do
  6. Say 'Could not access WB2 rexxdossupport.library'
  7. exit 20
  8. end
  9. Options Results
  10. template="PORT/A,LINE/A,CFG/K";cfg=""
  11. if arg()=0 then do;say template;exit;end
  12. parse arg args
  13. if ~ReadArgs(args,template) then do;say Fault(RC,template);exit 10;end
  14. else do
  15.   LG=lower(port)'wpl';line=strip(line)
  16.   if cfg="" then cfg="CFG:RFH.CFG"
  17. end
  18. sv="v"right(v,5);app="RFH "sv;MP="RFH"line;mport=upper(port)||line
  19. Options failat 99
  20. numeric digits 14
  21. Signal On Syntax
  22. signal on halt
  23. cr='0D'x;lf="0A"x;LBUF="";ABUF="";MBUF=""
  24. HydraReq='T:HydraReq.'||line
  25. if showlist('P',MP) then do;address LOGPROC 'Putlog 'LG time() line MP': 'app' already open';exit 10;end
  26. if ~openport(MP) then do;address LOGPROC 'Putlog 'LG time() line MP': Could not open 'MP', quitting';exit 10;end
  27. call setconfig()
  28. r.1='Unregistered Node';r.2='Excluded Node';r.3='Excluded Point';r.4='Unlisted System'
  29. e.1='Duplicate Request Ignored';e.2='File Not Found';e.3='Password Missing or Invalid'
  30. e.4='File Not Available On This System';e.5='Request Exceeded Maximum Requests';e.6='Request Exceeded Byte count'
  31. nl.0='Unlisted'
  32. nl.1='Listed'
  33. address LOGPROC 'Putlog 'LG time() line app 'Ready'
  34. quitflag=0
  35. do forever
  36.   drop p entry RFunc cmdword
  37.   if quitflag=1 then leave
  38.   t=waitpkt(MP)
  39.   do ff=1
  40.     p=getpkt(MP)
  41.     if c2d(p)=0 then leave ff
  42.     RFunc=getarg(p)
  43.     cmdword=(upper(word(RFunc,1)))
  44.     if cmdword="REQ" | cmdword="RFHCFG" | cmdword="RFHSHOW" | cmdword="RFHEXIT" then call reply(p,0)
  45.     else call reply(p,5)
  46.     select
  47.       when cmdword="REQ" then do
  48.         Parse var RFunc junk' 'baud H_A Infile Listed FNC HYD R_A R_S
  49.         xfq_site_object=XfqGetAddress(R_A)
  50.         if ~XfqHoldMailer(xfq_site_object) then do
  51.           address LOGPROC 'Putlog 'LG time() line MP 'HOLD Failed:'XFQERRORMSG R_A
  52.           drop XFQERRORCODE XFQERRORMSG
  53.         end;else do
  54.           call do_req()
  55.           drop junk Baud H_A Infile Listed FNC HYD R_A R_S
  56.           drop NumRequested ReqName SendFname Fname Fsize Fdesc Mname Password Update UDT UpDt Jdate 
  57.           drop Num ReqCount SentCount SearchResult FirstDate NumReqs ReqFiles Sent ReqBytes TBytes LastBytes UserCalls
  58.           drop file sendas
  59.         end
  60.       end
  61.       when cmdword="RFHEXIT" then quitflag=1
  62.       when cmdword="RFHCFG" then call setconfig()
  63.       when cmdword="RFHSHOW" then call showconfig()
  64.       otherwise nop
  65.     end
  66.   end
  67. end
  68. address LOGPROC 'Putlog 'LG time() line MP 'port closed'
  69. exit
  70.  
  71. do_req:
  72. parse var R_A hisaddress.domain '#' hisaddress.zone ':' hisaddress.net '/' hisaddress.node '.' hisaddress.point .
  73. R_S=strip(R_S);if R_S="" then R_S="Unknown Sysop"
  74. address LOGPROC 'Putlog 'LG time() Line app 'Serving 'R_S' of 'nl.Listed R_A' on 'MPORT' FNC:'fnc' HYD:'hyd
  75. HBUF="";LBUF="";ABUF="";MBUF="";pbuf="";tlist="T:RFH_t"Line;ulist="T:RFH_u"Line;a=0;b=0;i=0;x=0;Sent=0;TBytes=0
  76. FreqLst=SFreqLst
  77. LBUF=LBUF||date() time()' RFH Serving 'R_S' of 'nl.Listed R_A' on 'MPORT||lf
  78. parse var H_A myaddress.domain '#' myaddress.zone ':' myaddress.net '/' myaddress.node '.' myaddress.point
  79. if HYD=1 then SessMaxReqNames=3;else SessMaxReqNames=MaxReqNames
  80.  
  81.  
  82. if ~ReqPoint & (hisaddress.point > "0") then return badsite(r.3,R_A,R_S)
  83. else if ~ReqUnlisted & ~Listed then return badsite(r.4,R_A,R_S)
  84.  
  85. /*if ~ReqPoint & (hisaddress.point > "0") then do */
  86. /*  call badsite(r.3,R_A,R_S);return  */
  87. /*end;else if ~ReqUnlisted & ~Listed then do  */
  88. /*  call badsite(r.4,R_A,R_S);return  */
  89. /*end */
  90.  
  91. if INCLUDE.0~=0 then do
  92.   validnode=0
  93.   do zz=1 to INCLUDE.0
  94.     if matchpattern(Include.zz,R_A,"N") then do
  95.       validnode=1
  96.       leave
  97.     end
  98.   end
  99.   if ~validnode then return badsite(r.1,R_A,R_S)
  100. end
  101. /*  if ~validnode then do */
  102. /*    call badsite(r.1,R_A,R_S);return  */
  103. /*  end */
  104. /*end */
  105. if EXCLUDE.0~=0 then do zz=1 to EXCLUDE.0
  106.   if matchpattern(Exclude.zz,R_A,"N") then return badsite(r.2,R_A,R_S)
  107. end
  108. /*  if matchpattern(Exclude.zz,R_A,"N") then do */
  109. /*    call badsite(r.2,R_A,R_S);return  */
  110. /*  end */
  111. /*end */
  112. if PRIVLEDGED.0~=0 then do zz=1 to PRIVLEDGED.0
  113.   if matchpattern(Privledged.zz,R_A,"N") then do
  114.     LBUF=LBUF||date() time() Line R_A 'granted privledged access'lf
  115.     if exists(PFreqLst) then FreqLst=PFreqLst
  116.     else LBUF=LBUF||date() time() Line 'Cannot find 'PFreqLst||lf
  117.   end
  118. end
  119. AcctFile=AcctPath||translate(R_A,'...','#:/')
  120. if exists(AcctFile) then do
  121.   call open('Acct',AcctFile,'R')
  122.   FirstDate=readln('Acct')
  123.   LastDate=readln('Acct')
  124.   NumReqs=readln('Acct')
  125.   ReqFiles=readln('Acct')
  126.   ReqBytes=readln('Acct')
  127.   LastBytes=readln('Acct')
  128.   UserCalls=readln('Acct')
  129.   call close('Acct')
  130.   if LastDate~=Date() then LastBytes=0
  131.   UserCalls=UserCalls+1
  132. end;else do
  133.   FirstDate=Date();LastDate=Date();NumReqs=0;ReqFiles=0;ReqBytes=0;LastBytes=0;UserCalls=0
  134. end
  135. SessBytes=MaxBytes
  136. if LIMITED.0~=0 then do zz=1 to LIMITED.0
  137.   if matchpattern(word(Limited.zz,1),R_A,"N") then do
  138.     SessBytes=word(Limited.zz,2)
  139.     address LOGPROC 'Putlog 'LG time() Line "Reducing Max Bytes for LIMITED site to "SessBytes
  140.     LBUF=LBUF||date() time() Line' Reducing Max Bytes to 'SessBytes' for 'R_S' of 'R_A' -> Limited Node!'lf
  141.     leave
  142.   end
  143. end
  144.  
  145. NumRequested=1
  146. if ~open(RQ,Infile,'R') then do
  147.   address LOGPROC 'Putlog 'LG time() Line "Unable to read "Infile
  148.   LBUF=LBUF||date() time() Line Infile' from 'R_S' of 'R_A' -> Not Found'lf
  149.   return end_session()
  150. end
  151. do while ~eof(RQ)
  152.   FName.NumRequested=upper(strip(readln(RQ),"B",CR))
  153.   MName.NumRequested=""
  154.   if left(FName.NumRequested,1)=";" | left(FName.NumRequested,3)="---" then iterate
  155.   if right(FName.NumRequested,1)=D2C('13') then FName.NumRequested=left(FName.NumRequested,Length(FName.NumRequested)-1)
  156.   if length(FName.NumRequested) < 1 then leave
  157.   Update.NumRequested=""
  158.   Password.NumRequested=""
  159.   if words(FName.NumRequested) > 1 then do
  160.     if left(word(FName.NumRequested,2),1)="!" then Password.NumRequested=SubStr(Word(FName.NumRequested,2),2)
  161.     if left(word(FName.NumRequested,2),1)="+" then Update.NumRequested=Word(FName.NumRequested,2)
  162.     else if left(word(FName.NumRequested,2),1)="-" then Update.NumRequested=Word(FName.NumRequested,2)
  163.     else if words(FName.NumRequested)=3 then do
  164.       if left(word(FName.NumRequested,3),1)="!" then Password.NumRequested=SubStr(Word(FName.NumRequested,3),2)
  165.       if left(word(FName.NumRequested,3),1)="+" then Update.NumRequested=Word(FName.NumRequested,3)
  166.       else if left(word(FName.NumRequested,3),1)="-" then Update.NumRequested=Word(FName.NumRequested,3)
  167.     end
  168.     FName.NumRequested=word(FName.NumRequested,1)
  169.   end
  170.   NumRequested=NumRequested+1
  171. end
  172. call close(RQ)
  173. NumRequested=NumRequested-1
  174. call FindRequests
  175. do a=1 to NumRequested
  176.   if (SessMaxReqNames>0 & a>SessMaxReqNames) | SendFName.a.SentFiles=0 then SendFName.a.SentFiles=1
  177.   do b=1 to SendFName.a.SentFiles
  178.     if SendFName.a.b="Duplicate Request Ignored" then do;call RspErr(e.1,a,FName.a);iterate;end
  179.     else if SendFName.a.b="File Not Found" then do;call RspErr(e.2,a,FName.a);iterate;end
  180.     else if SendFName.a.b="Bad Password" then do;call RspErr(e.3,a,FName.a,Password.a);iterate;end
  181.     else if SendFName.a.b="File Not Available" then do;call RspErr(e.4,a,FName.a,Password.a);iterate;end
  182.     else if SendFName.a.b="Too Many Requests" | (SessMaxReqNames>0 & a>SessMaxReqNames) then do;call RspErr(e.5,a,FName.a);iterate;end
  183.     else if SendFName.a.b="Too Many Bytes" then do;call RspErr(e.6,a,FName.a);iterate;end
  184.     else if SubWord(SendFName.a.b,1,3)="Update request failed:" then do
  185.       MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Date : 'JDate.a.b||cr'Error: 'SendFName.a.b||cr||cr
  186.       LBUF=LBUF||date() time()' 'FName.a' -=> Error: 'SendFName.a.b||lf
  187.       iterate
  188.     end;else do
  189.       Sent=Sent+1
  190.       if MName.a.b~="" then do
  191.         MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||' Sent:'MName.a.b||cr'Size : 'FSize.a.b' bytes'cr'Desc : 'FDesc.a.b||cr||cr
  192.         LBUF=LBUF||date() time()' 'FName.a '['MName.a.b'] ('FSize.a.b' bytes)'lf
  193.       end;else do
  194.         MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Size : 'FSize.a.b' bytes'cr'Desc : 'FDesc.a.b||cr||cr
  195.         LBUF=LBUF||date() time()' 'FName.a' ('FSize.a.b' bytes)'lf
  196.       end
  197.     end
  198.   end
  199. end
  200. if (SessMaxReqNames>0) & (NumRequested>SessMaxReqNames) then MBUF=MBUF||'Remaining Requests skipped for exceeding request limits'cr
  201. call writepkt(MBUF)
  202. if SysopReport then call writepkt(MBUF,'S')
  203. drop MBUF
  204. LBUF=LBUF||date() time()' Sending 'Sent' file(s), 'TBytes' bytes this request'lf||date() time()' Totals: 'NumReqs+1' request(s) for 'ReqFiles+Sent' file(s) ('ReqBytes+TBytes' bytes)'lf
  205. ABUF=ABUF||FirstDate||lf||Date()||lf||NumReqs+1||lf||ReqFiles+Sent||lf||ReqBytes+TBytes||lf||LastBytes+TBytes||lf||UserCalls||lf
  206.  
  207. if HYD then do
  208. if open(H,HydraReq,'A') then address LOGPROC 'PutLog 'LG time() Line MP "Appending to "HydraReq
  209. else do
  210.   if open(H,HydraReq,'W') then address LOGPROC 'PutLog 'LG time() Line MP "Creating "HydraReq
  211.   else do
  212.     address LOGPROC 'PutLog 'LG time() Line MP "Unable to write "HydraReq
  213.     return end_session()
  214.   end
  215. end
  216. call writech(H,Hbuf);call close(H);drop Hbuf
  217. call SetClip('HYDREQ'line,"OK")
  218. end
  219. return end_session()
  220.  
  221. FindRequests:
  222. Num=NumRequested
  223. if (SessMaxReqNames~=0) & (NumRequested>SessMaxReqNames) then Num=SessMaxReqNames
  224. LBUF=LBUF||date() time()' Using 'FreqLst||lf
  225. do ReqCount=1 to Num
  226.   address LOGPROC 'PutLog 'LG time() Line MP "Searching for Req:"ReqCount":"FName.ReqCount" in "FREQLST
  227.   SentCount=1;notfound=1
  228.   SendFName.ReqCount.SentCount="File Not Found"
  229.  
  230.   if ReqCount>1 then do
  231.     dupe=0
  232.     do fz=1 to ReqCount-1
  233.       if upper(Fname.ReqCount)=upper(Fname.fz) then dupe=1
  234.     end
  235.     if dupe then do
  236.       SendFName.ReqCount.SentCount="Duplicate Request Ignored"
  237.       address LOGPROC 'PutLog 'LG time() Line MP "Req:"ReqCount":"FName.ReqCount SendFName.ReqCount.SentCount
  238.       Iterate
  239.     end
  240.   end
  241.   sopt=""
  242.   if SortedLst then sopt="-s"
  243.   if MatchFirst then address COMMAND 'Fsearch >'tlist FREQLST Fname.ReqCount '-o' sopt
  244.   else address COMMAND 'Fsearch >'tlist FREQLST Fname.ReqCount sopt
  245.   call open('tq',tlist,'r')
  246.   do while ~eof('tq')
  247.     SearchResult=strip(readln('tq'))
  248.     if SearchResult="" then Iterate
  249.     if SearchResult="!@ No match found" then do
  250.       SendFName.ReqCount.SentCount="File Not Found"
  251.       Leave
  252.     end
  253.     if MatchFirst then do
  254.       call sendifok
  255.       Leave
  256.     end
  257.     call sendifok
  258.     SentCount=SentCount+1
  259.     if MultiMagic | ~MatchFirst then Iterate;else Leave
  260.   end
  261.   call close('tq');call delete(tlist)
  262.   if SentCount=0 then SendFname.ReqCount.SentFiles=1
  263.   else if SentCount > 1 then SendFname.ReqCount.SentFiles=SentCount-1
  264.   else SendFname.ReqCount.SentFiles=SentCount
  265. end
  266. Return
  267.  
  268. sendifok:
  269. sendit=1
  270. if index(SearchResult,'!')=0 then SendFname.ReqCount.SentCount=upper(subword(SearchResult,2))
  271. else do
  272.   if upper(Password.ReqCount)~=strip(upper(delstr(word(SearchResult,2),1,1))) then do
  273.     SendFName.ReqCount.SentCount="Bad Password"
  274.     sendit=0
  275.   end;else SendFname.ReqCount.SentCount=upper(subword(SearchResult,3))
  276. end
  277. if ~sendit then return sendit
  278. if ~exists(SendFName.ReqCount.SentCount) then do
  279.   SendFName.ReqCount.SentCount="File Not Available"
  280.   sendit=0
  281. end;else do
  282.   FName.ReqCount.SentCount=get_fn(SendFName.ReqCount.SentCount)
  283.   filestats=statef(SendFName.ReqCount.SentCount)
  284.   FSize.ReqCount.SentCount=word(filestats,2)
  285.   TBytes=TBytes+FSize.ReqCount.SentCount
  286.   if SessBytes>0 & (TBytes>SessBytes) then do
  287.     SendFName.ReqCount.SentCount="Too Many Bytes"
  288.     TBytes=TBytes-FSize.ReqCount.SentCount
  289.     sendit=0
  290.   end
  291.   if (MaxDaily > 0) & (TBytes+LastBytes > MaxDaily) then do
  292.     SendFName.ReqCount.SentCount="Exceeded Daily Limit"
  293.     TBytes=TBytes-FSize.ReqCount.SentCount
  294.     sendit=0
  295.   end
  296.   FDesc.ReqCount.SentCount=get_fd(SendFName.ReqCount.SentCount,filestats)
  297.   if FDesc.ReqCount.SentCount="" then FDesc.ReqCount.SentCount="Sorry, description is unavailable"
  298.  
  299.   if Update.ReqCount ~="" then do
  300.     UDT.ReqCount=left(Update.ReqCount,1)
  301.     if substr(Update.ReqCount,2,1)="U" then do
  302.       Update.ReqCount=SubStr(Update.ReqCount,3)
  303.       UDT.Human=1
  304.     end;else do
  305.       Update.ReqCount=SubStr(Update.ReqCount,2)
  306.       UDT.Human=0
  307.     end
  308.     if UDT.Human then do
  309.       if length(strip(Update.ReqCount)) >6 then do
  310.         cktime=1
  311.         cmd='List DATES 'SendFName.ReqCount.SentCount' LFORMAT="%D%T" TO 'ulist
  312.       end;else do
  313.         cktime=0
  314.         cmd='List DATES 'SendFName.ReqCount.SentCount' LFORMAT="%D" TO 'ulist
  315.       end
  316.       Address Command cmd
  317.       call open('UFile',ulist,'R')
  318.       UpDt.ReqCount.SentCount=readln('UFile')
  319.       call close('UFile')
  320.       call Delete(ulist)
  321.       if cktime then UpDt.ReqCount.SentCount=space(translate(UpDt.ReqCount.SentCount,"",":"),0)
  322.       Mon=right('00'||(pos(substr(UpDt.ReqCount.SentCount,4,3),'JanFebMarAprMayJunJulAugSepOctNovDec')+2)/3,2)
  323.       if cktime then Jdate.ReqCount.SentCount=right(UpDt.ReqCount.SentCount,2)||Mon||left(UpDt.ReqCount.SentCount,2)||right(UpDt.ReqCount.SentCount,8)
  324.         else Jdate.ReqCount.SentCount=right(UpDt.ReqCount.SentCount,2)||Mon||left(UpDt.ReqCount.SentCount,2)
  325.     end;else do
  326.       x=statef(SendFName.ReqCount.SentCount)
  327.       JDate.ReqCount.SentCount=(86400*365*8)+(2*86400)+(((word(x,5))*86400)+(word(x,6)*60))
  328.     end
  329.     if (UDT.ReqCount="+") & (JDate.ReqCount.SentCount < Update.ReqCount) then do
  330.       SendFName.ReqCount.SentCount="Update request failed: File older than requested."
  331.       sendit=0
  332.     end
  333.     if (UDT.ReqCount="-") & (JDate.ReqCount.SentCount > Update.ReqCount) then do
  334.       SendFName.ReqCount.SentCount="Update request failed: File newer than requested."
  335.       sendit=0
  336.     end
  337.   end
  338. end
  339. if sendit then do
  340.   Mname.ReqCount.SentCount=get_fn(SendFname.ReqCount.SentCount)
  341.   if Fname.ReqCount=Mname.ReqCount.SentCount then Mname.ReqCount.SentCount=""
  342.   sendas=get_fn(SendFName.ReqCount.SentCount)
  343.   if FNC then do
  344.     mBUF=mBUF||cr'FileName Requested with EMSI FNC flag:'sendas||cr
  345.     lastp=lastpos('.',sendas)
  346.     if pos('.',sendas)~=lastp then sendas=space(overlay('.',translate(sendas,' ','.'),lastp,1),0)
  347.     sendas=compress(sendas,xrange('20'x,'2d'x)'2f'x||xrange('3a'x,'40'x)xrange('5b'x,'60'x)xrange('7b'x,'7f'x))
  348.     parse var sendas n '.' xx
  349.     sendas=strip(left(n,8))"."strip(left(xx,3))
  350.     drop n xx    
  351.     mBUF=mBUF||cr'FileName Converted per EMSI FNC flag:'sendas||cr
  352.   end
  353.   call queueadd(SendFName.ReqCount.SentCount,sendas,4)
  354. end
  355. return sendit
  356.  
  357. writepkt:
  358. sysrpt=arg(2)=="S"
  359. magicnum=x2d(time('s'))+randu(x2d(Pragma('ID')))+(randu(x2d(time('s')))*999999)+(random()*1000000)
  360. serial=reverse(right("0000"x||c2x(magicnum),8))
  361. if ~sysrpt then packet_name="T:"serial".PKT"
  362. else do
  363.   packet_name=get_path(Infile)||serial".PKT"
  364.   myaddress.imp_point=1
  365. end
  366.  
  367. d=date("S");t=time("N");parse var t hh":"mm":"ss
  368. yr=reverse(right("00"x||d2c(left(d,4)),2));mh=reverse(right("00"x||d2c((substr(d,5,2)-1)),2));dy=reverse(right("00"x||d2c(substr(d,7,2)),2))
  369. hr=reverse(right("00"x||d2c(hh),2));mn=reverse(right("00"x||d2c(mm),2));sc=reverse(right("00"x||d2c(ss),2))
  370.  
  371. zo=reverse(right("00"x||d2c(myaddress.zone),2));ndo=reverse(right("00"x||d2c(myaddress.node),2))
  372. nto=reverse(right("00"x||d2c(myaddress.net),2));po=reverse(right("00"x||d2c(myaddress.point),2))
  373. if sysrpt then do
  374.  po=reverse(right("00"x||d2c(myaddress.imp_point),2))
  375.  zd=reverse(right("00"x||d2c(myaddress.zone),2));ndd=reverse(right("00"x||d2c(myaddress.node),2))
  376.  ntd=reverse(right("00"x||d2c(myaddress.net),2));pd=reverse(right("00"x||d2c(myaddress.point),2))
  377. end;else do
  378.  zd=reverse(right("00"x||d2c(hisaddress.zone),2));ndd=reverse(right("00"x||d2c(hisaddress.node),2))
  379.  ntd=reverse(right("00"x||d2c(hisaddress.net),2));pd=reverse(right("00"x||d2c(hisaddress.point),2))
  380. end
  381. pbuf=ndo||ndd||yr||mh||dy||hr||mn||sc||copies("00"x,2)||"0200"x||nto||ntd||"DA"x||d2c(substr(sv,2,2))||copies("00"x,8)
  382. pbuf=pbuf||zo||zd||copies("00"x,2)||reverse(right("01"x||"00"x,2))||"00"x||d2c(substr(sv,5,2))||reverse(right("00"x||"01"x,2))
  383. pbuf=pbuf||zo||zd||po||pd||"ROOF"||"0200"x||ndo||ndd||nto||ntd||"11000000"x||left(date(),6) right(date(),2) "" right("0"||time(),8)||"00"x
  384.  
  385. if sysrpt then pbuf=pbuf||"SYSOP"||"00"x||app||"00"x||"Report for "R_S" at "R_A||"00"x
  386. else do
  387.   pbuf=pbuf||R_S||"00"x||app||"00"x||"Results of your file request"||"00"x
  388.   if myaddress.zone~=hisaddress.zone then pbuf=pbuf||"01"x||"INTL" hisaddress.zone":"hisaddress.net"/"hisaddress.node myaddress.zone":"myaddress.net"/"myaddress.node||cr
  389.   else pbuf=pbuf||"01"x||"MSGTO:" hisaddress.zone":"hisaddress.net"/"hisaddress.node||cr
  390.   if myaddress.point~=0 then pbuf=pbuf||"01"x||"FMPT" myaddress.point||cr;if hisaddress.point~=0 then pbuf=pbuf||"01"x||"TOPT" hisaddress.point||cr
  391.   pbuf=pbuf||"01"x||"MSGID: "myaddress.zone':'myaddress.net'/'myaddress.node'.'myaddress.point' 'd2x((date('I') * 86400)+time("S")+252460600) ||cr
  392. end
  393. pbuf=pbuf||"01"x||"PID: "app||cr
  394.  
  395. if ~sysrpt then do
  396.   pbuf=pbuf||cr"    Presenting "app", the WPL File Request ARexx Function Host"cr||cr
  397.   pbuf=pbuf||cr'The following are the results of your File Request:'cr||cr||arg(1)||cr
  398.   pbuf=pbuf||cr'Sending 'Sent' file(s), 'TBytes' bytes this request.'cr||cr'You have made a total of 'NumReqs+1' FileRequest(s) for 'ReqFiles+Sent' files ('ReqBytes+TBytes' bytes)'cr
  399.   pbuf=pbuf||cr'Files were requested from 'app' on 'H_A||cr
  400. end;else do
  401.   pbuf=pbuf||cr' Inbound File Request Tracking'||cr||cr
  402.   pbuf=pbuf||cr'   Address                :'right_justify(R_A,23)
  403.   pbuf=pbuf||cr'   Sysop                  :'right_justify(R_S,23)
  404.   pbuf=pbuf||cr'   First Call             :'right_justify(Firstdate,23)
  405.   pbuf=pbuf||cr'   Last Call              :'right_justify(LastDate,23)
  406.   pbuf=pbuf||cr'   Number of Requests     :'right_justify(NumReqs+1,23)
  407.   pbuf=pbuf||cr'   Files Transfered       :'right_justify(SENT,23)
  408.   pbuf=pbuf||cr'   Total Files Transfered :'right_justify(ReqFiles+SENT,23)
  409.   pbuf=pbuf||cr'   Bytes Sent This Call   :'right_justify(TBytes,23)
  410.   pbuf=pbuf||cr'   Bytes Sent Last Call   :'right_justify(LastBytes,23)
  411.   pbuf=pbuf||cr'   Total Bytes Sent       :'right_justify(ReqBytes+Tbytes,23)
  412.   pbuf=pbuf||cr'   Number of Sessions     :'right_justify(Usercalls,23)
  413.   pbuf=pbuf||cr'   Daily limits           :'right_justify(MaxDaily,23)
  414.   pbuf=pbuf||cr'   Session Limit          :'right_justify(SessBytes,23)||cr
  415.   pbuf=pbuf||cr' Session Particulars'cr||arg(1)||cr
  416. end
  417. pbuf=pbuf||cr||cr||cr||"--- Shelter "app||cr||cr||"000000"x
  418. if ~open('packet',packet_name,"W") then do;address LOGPROC 'PutLog 'LG time() Line MP "Couldn't open packet-file ["packet_name"]";return 20;end
  419. call writech('packet',pbuf);call close('packet');drop pbuf
  420. if ~sysrpt then call queueadd(packet_name,get_fn(packet_name),5)
  421. return 0
  422.  
  423. get_path:
  424.   pos=lastPos('/',arg(1))
  425.   if pos=0 then pos=LastPos(':',arg(1))
  426. return substr(arg(1),1,pos)
  427.  
  428. right_justify:
  429. if length(arg(1))>arg(2) then return (right(arg(1),arg(2)))
  430. else return (copies(" ",arg(2)-length(arg(1)))||arg(1))
  431.  
  432. queueadd:
  433. file=upper(arg(1))
  434. sendas=arg(2)
  435. flags=arg(3)
  436. if HYD then do
  437.   Hbuf=Hbuf||file sendas||'0a'x
  438.   return 0
  439. end
  440. WORK=NULL 
  441. /*QUERY.XQ_NAME=file  */
  442. /*QUERY.XQ_SITE=xfq_site_object */
  443. /*WORK=XfqFindWork(QUERY) */
  444. /*if WORK=NULL then do  */
  445.   if ~XfqAddWorkQuick(R_A,file,sendas,120,flags) then do
  446.     address LOGPROC 'PutLog 'LG time() Line MP 'Queue 'file' Failed:'XFQERRORMSG R_A
  447.     drop XFQERRORCODE XFQERRORMSG
  448.   end;else do
  449.     address LOGPROC 'PutLog 'LG time() Line MP 'Queued 'file' as' sendas
  450.   end
  451. /*end;else do */
  452. /*  call XfqUnlockWork(WORK)  */
  453. /*  address LOGPROC 'PutLog 'LG time() Line MP file 'already queued'  */
  454. /*end */
  455. /*if WORK~=NULL then call XfqDropObject(WORK) */
  456. return 0
  457.  
  458. get_fn:
  459. if LastPos('/',arg(1))~=0 then return SubStr(arg(1),LastPos('/',arg(1))+1)
  460. else if LastPos(':',arg(1))~=0 then return SubStr(arg(1),LastPos(':',arg(1))+1)
  461. else return arg(1)
  462.  
  463. badsite:
  464. address LOGPROC 'Putlog 'LG time() Line "Refusing Request! "arg(1)
  465. LBUF=LBUF||date() time() Line' Refusing request from 'arg(3)' of 'arg(2)' -> 'arg(1)||lf
  466. call writepkt('File request terminated: 'arg(1)||cr)
  467. return end_session()
  468.  
  469. RspErr:
  470. MBUF=MBUF||'Request Number 'arg(2) 'Requested: 'arg(3)||cr'Error: 'arg(1)||cr||cr
  471. LBUF=LBUF||date() time()' 'FName.a' -=> Error: 'arg(1) arg(4)||lf
  472. return
  473.  
  474. setconfig:
  475. if ~open('cf',cfg,'r') then 
  476.  if ~open('cf',"RAM:RFH.cfg",'r') then 
  477.   if ~open('cf',"CFG:RFH.cfg",'r') then do;address LOGPROC 'PutLog 'LG time() Line 'Could not read RFH.cfg';exit;end
  478. exidx=1;ixidx=1;lxidx=1;pxidx=1
  479. do while ~eof('cf')
  480.   lx=readln('cf')
  481.   if lx="" | left(lx,1)=" " | left(lx,2)='/*' | left(lx,2)='*/' then iterate
  482.   parse var lx vn vv junkcomment
  483.   vn=upper(vn);vv=strip(vv)
  484.   select
  485.     when vn="PRIORITY" then priority=vv
  486.     when vn="SYSOPREPORT" then SysopReport=vv=="TRUE"
  487.     when vn="REQPOINT" then ReqPoint=vv=="TRUE"
  488.     when vn="REQUNLISTED" then ReqUnListed=vv=="TRUE"
  489.     when vn="SORTEDLST" then SortedLst=vv=="TRUE"
  490.     when vn="MULTIMAGIC" then MultiMagic=vv=="TRUE"
  491.     when vn="MATCHFIRST" then MatchFirst=vv=="TRUE"
  492.     when vn="FREQLST" then SFreqLst=dequote(vv)
  493.     when vn="PRIVLST" then PFreqLst=dequote(vv)
  494.     when vn="LOGFILE" then LogFile=dequote(vv)
  495.     when vn="ACCTPATH" then AcctPath=dequote(vv)
  496.     when vn="EXCLUDE" then do
  497.       EXCLUDE.exidx=translate(dequote(vv),"?","#")
  498.       exidx=exidx+1
  499.     end
  500.     when vn="INCLUDE" then do
  501.       INCLUDE.ixidx=translate(dequote(vv),"?","#")
  502.       ixidx=ixidx+1
  503.     end
  504.     when vn="LIMITED" then do
  505.       parse var junkcomment limit junkcomment
  506.       LIMITED.lxidx=translate(dequote(vv),"?","#")' 'limit
  507.       lxidx=lxidx+1
  508.     end
  509.     when vn="PRIVLEDGED" then do
  510.       PRIVLEDGED.pxidx=translate(dequote(vv),"?","#")
  511.       pxidx=pxidx+1
  512.     end
  513.     when vn="MAXBYTES" then MaxBytes=vv
  514.     when vn="MAXDAILY" then MaxDaily=vv
  515.     when vn="MAXREQNAMES" then MaxReqNames=vv
  516.     otherwise address LOGPROC 'Putlog 'LG time() Line MP 'Config Error:'lx
  517.   end
  518. end
  519. call close('cf')
  520. if exidx>0 then EXCLUDE.0=exidx-1;else EXCLUDE.0=0
  521. if ixidx>0 then INCLUDE.0=ixidx-1;else INCLUDE.0=0
  522. if lxidx>0 then LIMITED.0=lxidx-1;else LIMITED.0=0
  523. if pxidx>0 then PRIVLEDGED.0=pxidx-1;else PRIVLEDGED.0=0
  524. if EXCLUDE.0>0 & INCLUDE.0>0 then address LOGPROC 'Putlog 'LG time() Line MP 'Config Error: Cannot BOTH INCLUDE and EXCLUDE sites'
  525. drop lx vv vn junkcomment exidx ixidx lxidx
  526. if Priority~=0 then oldpri=Pragma('Priority',Priority)
  527. address LOGPROC 'Putlog 'LG time() Line MP 'Config loaded, Pri:'priority
  528. return
  529.  
  530.  
  531. showconfig:
  532. address LOGPROC 'Putlog 'LG time() Line 'Configuration'
  533. address LOGPROC 'Putlog 'LG time() Line 'Priority:'priority
  534. address LOGPROC 'Putlog 'LG time() Line 'reqPoint:'reqpoint
  535. address LOGPROC 'Putlog 'LG time() Line 'ReqUnlisted:'requnlisted
  536. address LOGPROC 'Putlog 'LG time() Line 'SortedLst:'sortedlst
  537. address LOGPROC 'Putlog 'LG time() Line 'MultiMagic:'multimagic
  538. address LOGPROC 'Putlog 'LG time() Line 'MatchFirst:'matchfirst
  539. address LOGPROC 'Putlog 'LG time() Line 'FREQLST:'sfreqlst
  540. address LOGPROC 'Putlog 'LG time() Line 'PRIVLST:'pfreqlst
  541. address LOGPROC 'Putlog 'LG time() Line 'Logfile:'logfile
  542. address LOGPROC 'Putlog 'LG time() Line 'AcctPath:'acctpath
  543. address LOGPROC 'Putlog 'LG time() Line 'MaxBytes:'maxbytes
  544. address LOGPROC 'Putlog 'LG time() Line 'MaxDaily:'maxdaily
  545. address LOGPROC 'Putlog 'LG time() Line 'MAxReqNames:'maxreqnames
  546. address LOGPROC 'Putlog 'LG time() Line 'Excludes:'exclude.0
  547. if exclude.0~=0 then do i=1 to exclude.0
  548.   address LOGPROC 'Putlog 'LG time() Line 'Excluded:'exclude.i
  549. end
  550. address LOGPROC 'Putlog 'LG time() Line 'Includes:'include.0
  551. if include.0~=0 then do i=1 to include.0
  552.   address LOGPROC 'Putlog 'LG time() Line 'Included:'include.i
  553. end
  554. address LOGPROC 'Putlog 'LG time() Line 'Limited:'limited.0
  555. if limited.0~=0 then do i=1 to limited.0
  556.   address LOGPROC 'Putlog 'LG time() Line 'Limited:'limited.i
  557. end
  558. address LOGPROC 'Putlog 'LG time() Line 'Privledged:'privledged.0
  559. if privledged.0~=0 then do i=1 to privledged.0
  560.   address LOGPROC 'Putlog 'LG time() Line 'Privledged:'privledged.i
  561. end
  562. return
  563.  
  564.  
  565. lower:
  566. return(bitor(arg(1),'20'x))
  567.  
  568. Syntax: call template_oops "Syntax(RC="RC")" sigl
  569. failure: call template_oops "Failure(RC="RC")" sigl
  570. halt: call template_oops "Halt" sigl 
  571. template_oops:
  572. parse arg what badline
  573. address LOGPROC 'PutLog 'LG time() Line MP "ERROR "what" Line:"badline
  574. call end_session()
  575. exit
  576.  
  577. end_session:
  578. x=XfqReleaseMailer(xfq_site_object)
  579. call XfqDropObject(xfq_site_object)
  580. if WORK~=NULL then call XfqDropObject(WORK)
  581. call XfqClose()
  582. if ABUF~="" then do
  583.   address LOGPROC 'PutLog 'LG time() Line "Updating account"
  584.   call open('Acct',AcctFile,'W')
  585.   call Writech('Acct',ABUF||lf)
  586.   call close('Acct')
  587.   drop ABUF
  588. end
  589. LBUF=LBUF||date() time()' RFH session Ending'lf
  590. if LogFile~="" then do
  591.   if exists(LogFile) then call open('log',LogFile,'A');else call open('log',LogFile,'W')
  592.   call writech('log',LBUF||lf);call close('log')
  593. end;else do
  594.   i=1
  595.   loglen=length(LBUF)
  596.   do while i < loglen+1
  597.     alen=pos('0a'x, LBUF, i)-i
  598.     aline=substr(body,i,alen)
  599.     address LOGPROC 'PutLog 'LG Line aline
  600.     i=i+alen+1
  601.   end
  602.   drop alen aline i
  603. end
  604. drop LBUF
  605. call delete(infile)
  606. address LOGPROC 'PutLog 'LG time() Line 'RFH session with' R_A 'terminated'
  607. return 0
  608.  
  609. dequote:
  610. parse arg thing
  611. parse var thing '"' unq_thing '"'
  612. if unq_thing ~= "" then return unq_thing
  613. return thing
  614.  
  615. get_fd:
  616. if ~compiled then return subword(arg(2),8) 
  617. else do
  618.   address COMMAND 'SetEnv DESC `LIST 'arg(1)' LFORMAT "%C"`'    
  619.   return GetVar('DESC',"G")
  620. end
  621. return
  622.